home *** CD-ROM | disk | FTP | other *** search
- unit OEDemoForm;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- ImgList, ComCtrls, ExtCtrls;
-
- type
- TSortOrder = ( soPriority, soAttachment, soFlag, soFrom, soSubject, soReceived );
-
- TForm1 = class(TForm)
- ToolbarImages: TImageList;
- Panel1: TPanel;
- Header: THeaderControl;
- ListView1: TListView;
- procedure HeaderSectionClick(HeaderControl: THeaderControl; Section: THeaderSection);
- private
- { Private declarations }
- procedure SortMessages (Order: TSortOrder; Ascending: Boolean);
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- procedure TForm1.HeaderSectionClick (HeaderControl: THeaderControl; Section: THeaderSection);
- var
- Idx: Integer;
- Sec: THeaderSection;
- SortAscending: Boolean;
- SortOrder: TSortOrder;
- begin
- // Just to shut the compiler up!
- SortOrder := soReceived; SortAscending := True;
- with Section do begin
- // Firstly, figure out which section this is.
- if ImageIndex = 4 then SortOrder := soPriority else
- if ImageIndex = 5 then SortOrder := soAttachment else
- if ImageIndex = 33 then SortOrder := soFlag else
- if Text = 'From' then SortOrder := soFrom else
- if Text = 'Subject' then SortOrder := soSubject else
- if Text = 'Received' then SortOrder := soReceived;
-
- // Next, redisplay sort marker according to selected section
- if Text <> '' then begin
- if ImageIndex = -1 then SortAscending := True else
- SortAscending := ImageIndex = 2;
- ImageIndex := 2 + Ord (SortAscending);
- end;
-
- // Next, remove sort marker from any other columns
- for Idx := 0 to Header.Sections.Count - 1 do begin
- Sec := Header.Sections [Idx];
- if (Sec <> Section) and (Sec.ImageIndex in [2, 3]) then Sec.ImageIndex := -1;
- end;
-
- // Finally, the sort !
- SortMessages (SortOrder, SortAscending);
- end;
- end;
-
- procedure TForm1.SortMessages (Order: TSortOrder; Ascending: Boolean);
- begin
- // An exercise for the reader....
- end;
-
- end.
-
-
-